#coding:utf-8
import base64
import pyDes

class Des(object):
    def __init__(self, time_str, machine):
        self.key = '12345678'
        self.machine = machine
        self.time_str = time_str

    def encrypt(self, data):
        k = pyDes.triple_des(self.key, pyDes.CBC, self.machine, pad=None, padmode=pyDes.PAD_PKCS5)
        d = k.encrypt(data)
        d = base64.encodestring(d)
        return d

    def decrypt(self, data):
        k = pyDes.triple_des(self.key, pyDes.CBC, self.machine, pad=None, padmode=pyDes.PAD_PKCS5)
        data = base64.decodestring(data)
        d = k.decrypt(data)
        return d